package com.atguigu.mvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @date: 2021/12/14 10:57
 * @description:
 */
@Controller
public class TsetScope {
    @RequestMapping("/testScopeServletAPI")
    private String testScope(HttpServletRequest request){
        request.setAttribute("testScopeServletAPI","helle,servletAPI");
        return "success";
    }
    @RequestMapping("/testModelAndView")
    private ModelAndView testModelAndView(){
        ModelAndView mav = new ModelAndView();
        mav.addObject("testModelAndView", "testModelAndView");
        mav.setViewName("success");
        return mav;
    }
    @RequestMapping("/testModel")
    private String testModel(Model model){
        model.addAttribute("testModel", "testModel");
        return "success";
    }
    @RequestMapping("/testMap")
    private String testMap(Map<String,Object> map){
        map.put("testMap", "testMap");
        return "success";
    }
    @RequestMapping("/testModelMap")
    private String testModelMap(ModelMap modelMap){
        modelMap.addAttribute("testModelMap", "testModelMap");
        return "success";
    }
}
